<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel=stylesheet type="text/css" href="../marvinmanuals.css">
<title>Step-by-step instructions for plugin teaching</title>
</head>
<body>
    <h1>Instructions for plugin teaching</h1>

    <h2>General remarks about the p<i>K</i><sub>a</sub> teaching</h2>

    If you are not satisfied with the performance of the default p<i>K</i><sub>a</sub> calculator then
    you can take the advantage of the supervised p<i>K</i><sub>a</sub> learning method that is built
    into the p<i>K</i><sub>a</sub> calculator.

    <p>
    <b>What do you need to do in order to improve the accuracy of the p<i>K</i><sub>a</sub> calculation?</b>
    <br>
    First, you need to see clearly which ionization center(s) was predicted
    inaccurately by the p<i>K</i><sub>a</sub> calculator.
    You need to collect experimental data for that ionization center(s). The learning
    algorithm is based on linear regression analysis, therefore you need to collect a
    certain amount of experimental p<i>K</i><sub>a</sub> data otherwise the regression analysis will fail.
    There is no rule of thumb for what a large pool of data is required to perform a
    reliable p<i>K</i><sub>a</sub> teaching. If your purpose is to create a local model with the scope
    only for a certain types of chemical environment of the ionization
    center then it may be enough to collect a few representative structures. A more
    robust model, however, requires as many as possible diverse structures and
    p<i>K</i><sub>a</sub> values of the ionization center in question.
    <p>
    The next step of the teaching process is the input of the collected data into
    an sdf file. The file can be easily created by using the graphical user interface of Instant JChem.
<p>
    <b>What kind of information should be included in the sdf file?</b>

    <br>The structure of the molecules and their experimental p<i>K</i><sub>a</sub> value(s) and atomic
    ID's which are assigned to the appropiate p<i>K</i><sub>a</sub> value(s).
    <p>
    After preparing the sdf file you can run the teaching algorithm that
    creates a correction library from your data. This correction library will be
    used by the p<i>K</i><sub>a</sub> calculation of the ionization
    center in question.

   
<!--     <p>This guide is a step-by-step manual for creating and using a
        training set that can be applied for the trainable calculations of Calculator
        Plugins (p<i>K</i><sub>a</sub>, log<i>P</i>).
    </p>

    <p>The training of the plugin starts with a file where you collect your
    experimental data (step 1, see below). From this, you generate a file which serves as knowledge
    base for the plugin (step 2), that you have to copy to a directory where the plugin
    picks it for usage (step 3). The plugin calculation will consider this knowledge base
    file if you turn on this option when running the calculation (step 4).

    <p>Please note that logP knowledge base needs a large set of data -
even your molecules are members of a small compound family. If you train your
plugin for benzene derivatives, you might find that values for cyclohexane
derivatives will be miscalculated.-->


    <h3><a name="pkatraining" type="anchor"></a>Training of the p<i>K</i><sub>a</sub> plugin</h3>

    <ol>
        <li><b>Create a training set in sdfile (.sdf)
            format</b> from your experimental data. The file must
            contain the following fields:
            <ul>
                <li>structure</li>
                <li>p<i>K</i><sub>a</sub> value 1 (field name: pKa1)</li>
            <li>ID of the atom which has the pKa1 value (field name: ID1)</li></ul>
            Additional p<i>K</i><sub>a</sub> values are optional (recommended for handling multiprotic compunds):
            <ul>
                <li>p<i>K</i><sub>a</sub> value 2 (pKa2)</li>
                <li>ID2</li>
                <li>etc.</li>
            </ul>
            Definition of only one p<i>K</i><sub>a</sub> value is enough to apply the
            training data, but more values in case of multiprotic compounds will enhance the
            reliability of the p<i>K</i><sub>a</sub> teaching.
            <p>
            In this example this file is <a href="training_files/mydata.sdf">mydata.sdf</a>.
            <br>The picture below is a detail from the training file. ID1 is the index
            of the atom with the experimental p<i>K</i><sub>a</sub>1 value (ID2 would
            be the index of the second measured p<i>K</i><sub>a</sub> value /p<i>K</i><sub>a</sub>2/, etc.).
            This atom index can be viewed by checking the Atom number option in the molecule editor (menu: View-&#62;Misc).
            <br><img src="training_files/mydata_zoomedmol.PNG" width="665" height="465" alt="mydata"/>
        </li>
        <li><b>Generation of the knowledge base:</b>
            Execute the following command from command line (in this example with the home directory path for Linux):
            <pre>cxcalc -T pKa -o /home/myaccount/ChemAxon/MarvinBeans mydata.sdf</pre> (option <code>-o</code> gives the location of the folder.)
            A 'pKaReg' folder will be created containing the training data.
			<b>Create a folder called <i>config</i></b> in the Marvin installation directory. 
            <br>If Marvin's default installation was followed, Marvin installation directory is located in:
            <ul>
                <li>Windows: C:\Program Files\ChemAxon\MarvinBeans</li>
                <li>Linux: USERHOME/ChemAxon/MarvinBeans (e.g. /home/myaccount/ChemAxon/MarvinBeans)</li>
                <li>OS X: /Applications/ChemAxon/MarvinBeans</li>
            </ul>
       <br>
    <b>Copy</b> the created pKaReg folder <b>to the config folder</b>.</li>


        <li><b>Use this knowledge base</b> via cxcalc, Chemical Terms or Marvin. The training data helps
            to calculate more accurately the p<i>K</i><sub>a</sub> of the
            molecules and the results are closer to the experimental values.
</ol>
    <h4>Usage in Marvin</h4>
    <table border="0"><tr><td width="300">check the Use correction library box to activate the training option:</td>
            <td><img src="training_files/marvin_checkbox.PNG" width="199" height="403" alt="usage in Marvin"/></td>
        </tr>
    </table>

    <p>  <table border="0">
        <tr>
            <th>p<i>K</i><sub>a</sub> calculation without training data</th>
            <th>p<i>K</i><sub>a</sub> calculation with training data</th>
        </tr>
        <tr>
            <td><img src="training_files/no_training.png" width="372" height="164" alt="not trained"/>
            </td>
            <td><img src="training_files/trained.png" width="372" height="164" alt="trained"/>
            </td>
        </tr>
    </table>
    <p>
    <h4>
        Usage with <code>cxcalc</code></h4>
        <p>without correction library:
         <pre>
              cxcalc pKa "CC1=NC2=C(N1)C(C)=NC(C)=N2"
              id      apKa1   apKa2   bpKa1   bpKa2   atoms
              1       11.08           3.67    -2.38   6,9,3</pre>

        <p>with correction library:
         <pre>
              $ cxcalc pKa -c "CC1=NC2=C(N1)C(C)=NC(C)=N2"
              id      apKa1   apKa2   bpKa1   bpKa2   atoms
              1        9.90           3.67    -2.46   6,9,3</pre>

        <code>-c</code> use the correction library<br>


        <p>For more options see <a href="../applications/cxcalc-calculations.html#pka">this page</a>.

 <h2>General remarks about the log<i>P</i> teaching</h2>

    <p>You can create your own log<i>P</i> calculator with the supervised learning method built into the log<i>P</i> calculator.
    <p>
    What you need to do is just simple collect experimental logP data and create a sdf
    file from them. Details about the expected file format given below in the technical help.
    <p>
   <b> What do you need to see clearly in log<i>P</i> model building?</b>
    <p>
    If you create a local log<i>P</i> model then the scope of  the log<i>P</i> calculator will be
    limited. It means that the calculated log<i>P</i> will only provide reasonable prediction
    for a few types of structures. Practically only those types of structures will be
    predicted correctly which were introduced to the training set during the teaching process.
    For example, if the training set contains only certain types of hydrocarbon and
    no other functional groups are present in the training set then it's not to expect
    that the predicted log<i>P</i> of any amine-like structure will be accurate.
    <p>
    In other words, you need to be aware that a more robust general log<i>P</i> model requires a
    large, diverse training set with thousands of structures.

    <h3><a name="logptraining" type="anchor"></a>Training of the log<i>P</i> plugin</h3>
    <ol>
        <li><b>Create a structure file of any molecule file format</b> from your experimental
            data. The file must contain the following information:
            <ul>
                <li>structure</li>
                <li>logP values in a property field named LOGP</li>
            </ul>
            In this example this file is <a href="training_files/trainingset.sdf">trainingset.sdf</a>.
        </li>
        <li><b>Execute the following command</b> from command line:
            <pre>cxcalc -T logP -t LOGP -o logPparameters.txt trainingset.sdf</pre>
            With the <code>-o</code> option you can define a path for the file generated.
            <b>Create a folder called <i>config</i></b> in the Marvin installation directory
            <br>If Marvin's default installation was followed, Marvin installation directory is located in:
            <ul>
                <li>Windows: C:\Program Files\ChemAxon\MarvinBeans</li>
                <li>Linux: USERHOME/ChemAxon/MarvinBeans (e.g. /home/myaccount/ChemAxon/MarvinBeans)</li>
                <li>OS X: /Applications/ChemAxon/MarvinBeans</li>
            </ul>
        </li>
        <li>Save the file to the config folder with the name <b>logPparameters.txt</b>.</li>

        <li>Use this data via  via cxcalc, Chemical Terms or Marvin.
        </li>
    </ol>



</body>
</html>
